package com.zxm.controller;

import java.util.List;

import org.apache.taglibs.standard.lang.jstl.test.beans.PublicInterface2;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.zxm.pojo.ContentCategory;
import com.zxm.result.EasyUiResult;
import com.zxm.result.GuhealthResult;
import com.zxm.result.TreeResult;
import com.zxm.service.ContentCategoryService;

@Controller
@RequestMapping("/content/category")
public class ContentCatagoryController {
	
	@Reference
	private ContentCategoryService contentCategoryService;
	
	@RequestMapping("/tree")
	public String tree() {
		return "/content/content-category-tree";
	}
	
	/**
	 * 获得树形结构列表
	 */
	@RequestMapping("/getTree")
	@ResponseBody
	public List<TreeResult> getTree(Long id){
		return contentCategoryService.getTree(id);
	}
	
	/**
	 * 执行商品内容的更新或者保存操作
	 */
	@RequestMapping("/saveOrUpdate")
	@ResponseBody
	public GuhealthResult saveOrUpdate(ContentCategory contentCategory) {
		return contentCategoryService.saveOrUpdate(contentCategory);
	}
	
	/**
	 * 递归删除树中的一个元素
	 */
	@RequestMapping("/delete")
	@ResponseBody
	public GuhealthResult delete(Long id) {
		return contentCategoryService.deleteById(id);
	}

}
